package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Brand;
import org.nf.shopping.service.BrandService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-12
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/brand")
public class BrandController extends BaseController{

    private final BrandService brandService;

    @GetMapping("/listBrand")
    public ResultVO<PageInfo<Brand>> listBrand(Integer limit, Integer page, String typeName){
        PageInfo<Brand> pageInfo = brandService.listBrand(limit, page, typeName);
        return success(pageInfo);
    }

    @PostMapping("/updateBrand")
    public ResultVO updateBrand(Brand brand){
        brandService.updateBrand(brand);
        return success();
    }

    @PostMapping("/deloneBrand")
    public ResultVO deloneBrand(Integer id){
        brandService.deloneBrand(id);
        return success();
    }

    @PostMapping("/addBrand")
    public ResultVO addBrand(Brand brand){
        brandService.addBrand(brand);
        return success();
    }

    @PostMapping("/getBrandList")
    public ResultVO<List<Brand>> getBrandList(){
        return success(brandService.getBrandList());
    }
}
